// SPDX-License-Identifier: GPL-2.0
#include "tegra194.dtsi"

#include <dt-bindings/mfd/max77620.h>

/ {
	model = "NVIDIA Jetson AGX Xavier";
	compatible = "nvidia,p2888", "nvidia,tegra194";

	aliases {
		ethernet0 = "/bus@0/ethernet@2490000";
		i2c0 = "/bpmp/i2c";
		i2c1 = "/bus@0/i2c@3160000";
		i2c2 = "/bus@0/i2c@c240000";
		i2c3 = "/bus@0/i2c@3180000";
		i2c4 = "/bus@0/i2c@3190000";
		i2c5 = "/bus@0/i2c@31c0000";
		i2c6 = "/bus@0/i2c@c250000";
		i2c7 = "/bus@0/i2c@31e0000";
		mmc0 = "/bus@0/mmc@3460000";
		mmc1 = "/bus@0/mmc@3400000";
		serial0 = &tcu;
	};

	chosen {
		bootargs = "console=ttyS0,115200n8";
		stdout-path = "serial0:115200n8";
	};

	bus@0 {
		ethernet@2490000 {
			status = "okay";

			phy-reset-gpios = <&gpio TEGRA194_MAIN_GPIO(G, 5) GPIO_ACTIVE_LOW>;
			phy-handle = <&phy>;
			phy-mode = "rgmii-id";

			mdio {
				#address-cells = <1>;
				#size-cells = <0>;

				phy: phy@0 {
					compatible = "ethernet-phy-ieee802.3-c22";
					reg = <0x0>;
					interrupt-parent = <&gpio>;
					interrupts = <TEGRA194_MAIN_GPIO(G, 4) IRQ_TYPE_LEVEL_LOW>;
					#phy-cells = <0>;
				};
			};
		};

		memory-controller@2c00000 {
			status = "okay";
		};

		serial@3110000 {
			status = "okay";
		};

		/* SDMMC1 (SD/MMC) */
		mmc@3400000 {
			cd-gpios = <&gpio TEGRA194_MAIN_GPIO(A, 0) GPIO_ACTIVE_LOW>;
		};

		/* SDMMC4 (eMMC) */
		mmc@3460000 {
			status = "okay";
			bus-width = <8>;
			non-removable;

			vqmmc-supply = <&vdd_1v8ls>;
			vmmc-supply = <&vdd_emmc_3v3>;
		};

		padctl@3520000 {
			avdd-usb-supply = <&vdd_usb_3v3>;
			vclamp-usb-supply = <&vdd_1v8ao>;

			ports {
				usb2-1 {
					vbus-supply = <&vdd_5v0_sys>;
				};

				usb2-3 {
					vbus-supply = <&vdd_5v_sata>;
				};

				usb3-0 {
					vbus-supply = <&vdd_5v0_sys>;
				};

				usb3-3 {
					vbus-supply = <&vdd_5v0_sys>;
				};
			};
		};

		rtc@c2a0000 {
			status = "okay";
		};

		pmc@c360000 {
			nvidia,invert-interrupt;
		};
	};

	bpmp {
		i2c {
			status = "okay";

			pmic: pmic@3c {
				compatible = "maxim,max20024";
				reg = <0x3c>;

				interrupt-parent = <&pmc>;
				interrupts = <24 IRQ_TYPE_LEVEL_LOW>;
				#interrupt-cells = <2>;
				interrupt-controller;

				#gpio-cells = <2>;
				gpio-controller;

				pinctrl-names = "default";
				pinctrl-0 = <&max20024_default>;

				max20024_default: pinmux {
					gpio0 {
						pins = "gpio0";
						function = "gpio";
					};

					gpio1 {
						pins = "gpio1";
						function = "fps-out";
						maxim,active-fps-source = <MAX77620_FPS_SRC_DEF>;
					};

					gpio2 {
						pins = "gpio2";
						function = "fps-out";
						maxim,active-fps-source = <MAX77620_FPS_SRC_DEF>;
					};

					gpio3 {
						pins = "gpio3";
						function = "fps-out";
						maxim,active-fps-source = <MAX77620_FPS_SRC_DEF>;
					};

					gpio4 {
						pins = "gpio4";
						function = "32k-out1";
						drive-push-pull = <1>;
					};

					gpio6 {
						pins = "gpio6";
						function = "gpio";
						drive-push-pull = <1>;
					};

					gpio7 {
						pins = "gpio7";
						function = "gpio";
						drive-push-pull = <0>;
					};
				};

				fps {
					fps0 {
						maxim,fps-event-source = <MAX77620_FPS_EVENT_SRC_EN0>;
						maxim,shutdown-fps-time-period-us = <640>;
					};

					fps1 {
						maxim,fps-event-source = <MAX77620_FPS_EVENT_SRC_EN1>;
						maxim,shutdown-fps-time-period-us = <640>;
						maxim,device-state-on-disabled-event = <MAX77620_FPS_INACTIVE_STATE_SLEEP>;
					};

					fps2 {
						maxim,fps-event-source = <MAX77620_FPS_EVENT_SRC_EN0>;
						maxim,shutdown-fps-time-period-us = <640>;
					};
				};

				regulators {
					in-sd0-supply = <&vdd_5v0_sys>;
					in-sd1-supply = <&vdd_5v0_sys>;
					in-sd2-supply = <&vdd_5v0_sys>;
					in-sd3-supply = <&vdd_5v0_sys>;
					in-sd4-supply = <&vdd_5v0_sys>;

					in-ldo0-1-supply = <&vdd_5v0_sys>;
					in-ldo2-supply = <&vdd_5v0_sys>;
					in-ldo3-5-supply = <&vdd_5v0_sys>;
					in-ldo4-6-supply = <&vdd_5v0_sys>;
					in-ldo7-8-supply = <&vdd_1v8ls>;

					vdd_1v0: sd0 {
						regulator-name = "VDDIO_SYS_1V0";
						regulator-min-microvolt = <1000000>;
						regulator-max-microvolt = <1000000>;
						regulator-always-on;
						regulator-boot-on;
					};

					vdd_1v8hs: sd1 {
						regulator-name = "VDDIO_SYS_1V8HS";
						regulator-min-microvolt = <1800000>;
						regulator-max-microvolt = <1800000>;
						regulator-always-on;
						regulator-boot-on;
					};

					vdd_1v8ls: sd2 {
						regulator-name = "VDDIO_SYS_1V8LS";
						regulator-min-microvolt = <1800000>;
						regulator-max-microvolt = <1800000>;
						regulator-always-on;
						regulator-boot-on;
					};

					vdd_1v8ao: sd3 {
						regulator-name = "VDDIO_AO_1V8";
						regulator-min-microvolt = <1800000>;
						regulator-max-microvolt = <1800000>;
						regulator-always-on;
						regulator-boot-on;
					};

					sd4 {
						regulator-name = "VDD_DDR_1V1";
						regulator-min-microvolt = <1100000>;
						regulator-max-microvolt = <1100000>;
						regulator-always-on;
						regulator-boot-on;
					};

					ldo0 {
						regulator-name = "VDD_RTC";
						regulator-min-microvolt = <800000>;
						regulator-max-microvolt = <800000>;
						regulator-always-on;
						regulator-boot-on;
					};

					ldo2 {
						regulator-name = "VDDIO_AO_3V3";
						regulator-min-microvolt = <3300000>;
						regulator-max-microvolt = <3300000>;
						regulator-always-on;
						regulator-boot-on;
					};

					vdd_emmc_3v3: ldo3 {
						regulator-name = "VDD_EMMC_3V3";
						regulator-min-microvolt = <3300000>;
						regulator-max-microvolt = <3300000>;
					};

					vdd_usb_3v3: ldo5 {
						regulator-name = "VDD_USB_3V3";
						regulator-min-microvolt = <3300000>;
						regulator-max-microvolt = <3300000>;
					};

					ldo6 {
						regulator-name = "VDD_SDIO_3V3";
						regulator-min-microvolt = <3300000>;
						regulator-max-microvolt = <3300000>;
					};

					ldo7 {
						regulator-name = "AVDD_CSI_1V2";
						regulator-min-microvolt = <1200000>;
						regulator-max-microvolt = <1200000>;
					};
				};
			};

			temperature-sensor@4c {
				compatible = "ti,tmp451";
				reg = <0x4c>;

				interrupt-parent = <&gpio>;
				interrupts = <TEGRA194_MAIN_GPIO(H, 2)
					      IRQ_TYPE_LEVEL_LOW>;
				vcc-supply = <&vdd_1v8ls>;

				#thermal-sensor-cells = <1>;
			};
		};
	};

	vdd_5v0_sys: regulator@0 {
		compatible = "regulator-fixed";
		regulator-name = "VIN_SYS_5V0";
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
		regulator-always-on;
		regulator-boot-on;
	};

	vdd_hdmi: regulator@1 {
		compatible = "regulator-fixed";
		regulator-name = "VDD_5V0_HDMI_CON";
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
		gpio = <&gpio TEGRA194_MAIN_GPIO(A, 3) GPIO_ACTIVE_HIGH>;
		enable-active-high;
	};

	vdd_3v3_pcie: regulator@2 {
		compatible = "regulator-fixed";
		regulator-name = "PEX_3V3";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		gpio = <&gpio TEGRA194_MAIN_GPIO(Z, 2) GPIO_ACTIVE_HIGH>;
		regulator-boot-on;
		enable-active-high;
	};

	vdd_12v_pcie: regulator@3 {
		compatible = "regulator-fixed";
		regulator-name = "VDD_12V";
		regulator-min-microvolt = <1200000>;
		regulator-max-microvolt = <1200000>;
		gpio = <&gpio TEGRA194_MAIN_GPIO(A, 1) GPIO_ACTIVE_HIGH>;
		regulator-boot-on;
	};

	vdd_5v_sata: regulator@4 {
		compatible = "regulator-fixed";
		regulator-name = "VDD_5V_SATA";
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
		gpio = <&gpio TEGRA194_MAIN_GPIO(Z, 1) GPIO_ACTIVE_HIGH>;
		enable-active-high;
	};
};
